/**
 * 提示消息
 */
function show_msg(obj) {
	if (obj.msg != '') {
		alert(obj.msg);
	}
	if (obj.status && obj.url != '') {
		window.location = obj.url;
	}
}

$(document).ready(function() {
	//顶部搜索按钮事件
	$('.userNav a.search').click(function () {
		$('.topSearch').fadeToggle(150);
	});
	
	//主导航条头像点击事件
	$('a.leftUserDrop').click(function () {
		$('.leftUser').slideToggle(200);
	});
	
	$(document).click(function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("leftUserDrop"))
		$(".leftUser").slideUp(200);
	});
	
	//当前导航条划入事件
	if ($('#breadcrumbs ul>li').length > 0) {
		$('#breadcrumbs').xBreadcrumbs();
	}
	
	//列表全选事件
	$(".titleIcon input:checkbox").click(function() {
		var checkedStatus = this.checked;
		$("#checkAll tbody tr td:first-child input:checkbox").each(function() {
			this.checked = checkedStatus;
			$(this).closest('tr').toggleClass("thisRow", this.checked);
		});
	});
	
	//列表选中时改变行颜色
	$('#checkAll tbody tr td:first-child input[type=checkbox]').change(function() {
		$(this).closest('tr').toggleClass("thisRow", this.checked);
	});
	
	$('#general .subNav>li>a').click(function () {
		$(this).next('ul').slideToggle(200);
	});
	
	$('.del').live('click', function() {
		return confirm('确认要删除？');
	});
	
	//===== Tooltips =====//

	$('.tipN').tipsy({gravity: 'n',fade: true, html:true});
	$('.tipS').tipsy({gravity: 's',fade: true, html:true});
	$('.tipW').tipsy({gravity: 'w',fade: true, html:true});
	$('.tipE').tipsy({gravity: 'e',fade: true, html:true});
	
	$('#TheDialog').dialog({
        autoOpen: false,
        width: 800,
        height: 500,
        title: '',
        buttons: {
            //"Gotcha": function () {
            //    $(this).dialog("close");
            //},
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
	
	$('.mypass').click(function () {
		var url = $(this).attr('href');
		$.get(url, function (res) {
			$('#TheDialog').html(res);
			$('#TheDialog').dialog('open');
		});
		return false;
    });
});